#ifndef _ACTORMANAGER_H
#define _ACTORMANAGER_H

#include <list>

#include "manager.h"

class Actor;

typedef std::list<Actor*> actorList;
typedef actorList::iterator actorIt;

/**
  * It's the list of the actors of the scene. It updates all the actors at time
  * and it allows to add or to delete actors dynamicly. It may be iterated
  * thanks to the iterator.
  */
class ActorManager : public Manager
{
  public:
    /** Constructor don't really too much */
    ActorManager();

    /** Calls @see clear() */
    ~ActorManager();

    /**
      * It's used to make a loop with all the actors. @see end().
      * @returns a iterator to the first actor.
      */
    actorIt begin();

    /**
      * It's used to make a loop with all the actors. @see begin().
      * @returns a iterator to the first actor.
      */
    actorIt end();

    /**
      * Frees all the actors and clean the list.
      */
    void clear();

    /**
      * Adds a actor to the list.
      */
    void addActor(Actor* a);
    
    /**
      * Adds a actor to the 'to delete' List. When @see isLogicTick() is called,
      * removes all those actors from the main.
      */
    void delActor(Actor* a);

    /**
      * @returns the actor's number.
      */
    unsigned size();

    /**
      * Removes all the actores from the 'to delete' list.
      * IsLogicTick is called for each actor.
      */
    void logicTick();

    /** IsGraphicTick is called for each actor. */
    void graphicTick(); 

  protected:

    actorList m_actualList;
    actorList m_toDeleteList;
};

#endif
